import axios from '@/plugins/axios'
import url from './url.js'

const LOGIN = {}

LOGIN.login = function(formData) {
	return axios.post(url.Login, formData);
}

LOGIN.logout = function() {
	return axios.get(url.Logout);
}

LOGIN.loginLogs = function(page, limit, user_id) {
	return axios.get(url.LoginLogs, {
		page: page,
		limit: limit,
		user_id: user_id
	});
}

LOGIN.permissions = function() {
	return axios.get(url.Permissions);
}

// 权限管理
// 获取角色
LOGIN.roles = function(page, limit) {
	return axios.get(url.Roles, {
		page: page,
		limit: limit
	})
}

// 获取单个角色
LOGIN.oneRole = function(name) {
	return axios.get(url.Role, {
		name: name
	})
}

// 删除角色
LOGIN.delRole = function(id) {
	return axios.del(url.Role, {
		id: id
	})
}

// 增加角色
LOGIN.role = function(data) {
	return axios.post(url.Role, data)
}

// 获取账号列表
LOGIN.users = function(page, limit, username) {
	return axios.get(url.Users, {
		page: page,
		limit: limit,
		username: username
	})
}

// 注册账号
LOGIN.user = function(data) {
	return axios.post(url.Register, data)
}

// 修改密码
LOGIN.userPwd = function(data) {
	return axios.post(url.UserPassword, data)
}

LOGIN.resetPassword = function(data) {
	return axios.post(url.Password, data)
}

LOGIN.code = function() {
	return axios.get(url.Cp)
}

export default LOGIN
